package uk.ac.ebi.bioinvindex.model.impl.processing;

import uk.ac.ebi.bioinvindex.model.impl.StudyImpl;

import javax.persistence.*;
import java.util.Collection;
import java.util.HashSet;

/**
 * User: Nataliya Sklyar (nsklyar@ebi.ac.uk)
 * Date: Jul 30, 2007
 */

@Entity
@Table(name = "processing")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "obj_type", discriminatorType = DiscriminatorType.STRING, length = 255)
public abstract class ProcessingImpl<Input extends NodeImpl, Output extends NodeImpl> extends GraphElementImpl {

	protected Collection<Input> inputNodes = new HashSet<Input>();

	protected Collection<Output> outputNodes = new HashSet<Output>();
	
	protected Collection<ProtocolApplication> protocolApplications = new HashSet<ProtocolApplication> ();


	protected ProcessingImpl() {
		super();
	}

	protected ProcessingImpl(StudyImpl study) {
		super(study);
	}

	protected ProcessingImpl(StudyImpl study, boolean original) {
		super(study, original);
	}

	@Transient
	public Collection<Input> getInputNodes() {
		return this.inputNodes;
	}

	public void addInputNode(Input inputNode) {
		if (inputNode == null) {
			throw new IllegalArgumentException("inputNode cannot be null");
		}
		this.inputNodes.add(inputNode);
	}

	@Transient
	public Collection<Output> getOutputNodes() {
		return this.outputNodes;
	}

	public void addOutputNode(Output outputNode) {
		if (outputNode == null) {
			throw new IllegalArgumentException("outputNode cannot be null");
		}
		this.outputNodes.add(outputNode);
	}

	protected void setInputNodes(Collection<Input> inputNodes) {
		this.inputNodes = inputNodes;
	}

	protected void setOutputNodes(Collection<Output> outputNodes) {
		this.outputNodes = outputNodes;
	}


	@Transient
	protected Collection<ProtocolApplication> getProtocolApplications () {
  	return protocolApplications;
  }

	protected void setProtocolApplications ( Collection<ProtocolApplication> protocolApplications ) {
  	this.protocolApplications = protocolApplications;
  }

	public void addProtocolApplication ( ProtocolApplication protocolApplication ) {
		if (protocolApplication == null) {
			throw new IllegalArgumentException("protocolApplication cannot be null");
		}
		this.protocolApplications.add ( protocolApplication );
	}


}
